function debounce(fn, wait) {
  let timeout
  return function () {
    clearTimeout(timeout)
    timeout = setTimeout(() => {
      fn.apply(this, arguments)
    }, wait)
  }
}
function throttle(fn, wait) {
  let flag = true
  return function () {
    if (!flag) return
    flag = false
    fn.apply(this, arguments)
    setTimeout(() => {
      flag = true
    }, wait)
  }
}
export { debounce, throttle }
